package top.wilbert.collegelink.search.controller;/**
 * @author augus
 * @create 2023-03-17-21:35
 */

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import top.wilbert.collegelink.common.utils.PageUtils;
import top.wilbert.collegelink.common.utils.R;
import top.wilbert.collegelink.search.service.ForumSearchService;
import top.wilbert.collegelink.search.vo.TalkSearchParam;
import top.wilbert.collegelink.search.vo.TalkSearchResult;

import java.util.Map;

/**
 * @ClassName:SearchController
 * @Description:
 * @author Augus
 * @date 2023/3/17 21:35
 * @Version 1.0
 **/
@RestController
@RequestMapping("search/search")
public class SearchController {

    @Autowired
    private ForumSearchService forumSearchService;

    /**
     * 关键词搜索话题信息
     * @param talkSearchParam
     * @return
     */
    @RequestMapping("/talkList")
    public R listPage(TalkSearchParam talkSearchParam){

        TalkSearchResult talkSearchResult = forumSearchService.searchTalk(talkSearchParam);
        PageUtils page = new PageUtils();
        BeanUtils.copyProperties(talkSearchResult,page);
        page.setList(talkSearchResult.getTalks());
        return R.ok().setData(page);
    }
}
